"""
Author : ZhengShiQi
DateTime: 2025/9/12 11:10
FileName: requests.py
description: 处理API请求模拟的端点
"""
from fastapi import APIRouter, Depends, HTTPException
from sqlalchemy.orm import Session
from app.models.schemas import MockApi, MockApiCreate
from app.services.request_service import get_request_records, create_request_record
from app.models.database import get_db

router = APIRouter(prefix="/requests", tags=["请求记录"])

@router.get("/", response_model=list[MockApi])
def read_request_records(skip: int = 0, limit: int = 100, db: Session = Depends(get_db)):
    records = get_request_records(db, skip=skip, limit=limit)
    return records

@router.post("/", response_model=MockApi)
def create_request_record_endpoint(request: MockApiCreate, db: Session = Depends(get_db)):
    return create_request_record(db=db, request=request)